﻿@using OpenIdProvider
@model OpenIdProvider.Models.User

@{
    var email = Model.Email;
    var realName = Model.RealName;

    var lastActivity = Model.LastActivityDate;

    ViewData["Title"] = "User - " + email;
}

<div class="user-info">
    @if (realName != null)
    {
        <text>
            <div class="user-attribute">Real Name</div>
            <div class="user-attribute-value real-name">@realName</div>
        </text>
    }

    <div class="user-attribute">Last Seen</div>
    <div class="user-attribute-value">@lastActivity.ToRelativeTimeSpan()</div>

    @if (Model.VanityProviderId.HasValue())
    {
        var vanityUrl = Model.GetVanityClaimedIdentifier().AbsoluteUri;
        <text>
        <div class="user-attribute">Vanity Id</div>
        <div class="user-attribute-value"><a href="@vanityUrl">@vanityUrl</a></div>
        </text>
    }

    <div class="edit-profile">
    @if (Current.LoggedInUser.IsAdministrator)
    {
        <a href="/user/@(Model.ProviderId)/edit">Edit Profile</a>
    }
    else
    {
        <a href="/user/edit">Edit Profile</a>
    }
    </div>
</div>

<div class="user-history">
    <h3>History</h3>
    <table class="tbl-data">
        <thead>
            <tr>
                <th>Type</th>
                <th>Comment</th>
                <th>IP</th>
                <th>Date</th>
            </tr>
        </thead>
        @{
            var even = true;
            foreach (var h in Model.GetHistory())
            {
                <tr class="@(even ? "even" : "odd")">
                    <td>@OpenIdProvider.Models.UserHistoryTypeId.GetDisplayName(h.UserHistoryTypeId)</td>
                    <td>@h.Comment</td>
                    <td>@h.IP</td>
                    <td>@h.CreationDate.ToRelativeTimeSpan()</td>
                </tr>
                
                even = !even;
            }
        }
    </table>
</div>